import React from "react"
import { Card } from 'antd';

import { Prompt } from "react-router-dom";

class router06 extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            name: "",

        }
    }

    render() {
        return (
            <Card title="Prompt组件" bordered={false}>
                <h4>如果输入框有值 提示跳不跳页</h4>
                <Prompt message={location => (
                    !!this.state.name ? `你想跳到 ${location.pathname}?` :true 
                )} />
                <p>{this.state.name}</p>
                <input onChange={(e) => {
                    this.setState({
                        name: e.target.value
                    })
                }} value={this.state.name} type="text" />

            </Card>
        )
    }
}
export default router06